﻿using Ledict.Core.Data;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ledict.ConditionExtract.DAL
{
    /// <summary>
    /// 用户所属部门DAL
    /// </summary>
    public class CoreDepartDAL
    {
        private string DbName;
        public CoreDepartDAL()
        {
            DbName = "UserJurisdiction";
        }

        /// <summary>
        /// 获取部门信息
        /// </summary>
        /// <returns>返回部门名称和部门id</returns>
        public DataTable GetCoreDepart()
        {
            string sql = " select O_DepartId,O_DepartName from T_Core_Depart ";
            Database db = DatabaseFactory.CreateDatabase(DbName);
            DbCommand dbCommand = db.GetSqlStringCommand(sql);

            DataTable otb = db.ExecuteDataSet(dbCommand).Tables[0];
            if (otb != null && otb.Rows.Count > 0)
            {
                return otb;
            }
            else
            {
                return new DataTable();
            }
        }
    }
}
